package MLB::Web::Medium;

# Copyright 2008 Ted Romer
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License,
# version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

use strict;
use warnings;

use base qw(Class::Accessor);

use Carp;
use Exporter::Lite;

our @EXPORT=qw(medium_from_raw_medium);

MLB::Web::Medium->mk_ro_accessors
    (qw(
        title
        url
        feed_code
        )
     );

sub medium_from_raw_medium {
    my $raw_medium = shift;
    if ( !defined($raw_medium) ) {
        croak("Must provide raw_medium");
    }

    return MLB::Web::Medium->new
        (
         {
             title     => $raw_medium->{title}->[0],
             url       => $raw_medium->{url}->[0]->{content},
             feed_code => $raw_medium->{'feed-code'},
         }
         );

}

1;

# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
